home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-28 | 2.9 KB | 92 lines | [TEXT/CWIE] |
- // Rectangle.h
-
- #ifndef Rectangle_h
- #define Rectangle_h
-
- #ifndef PointObject_h
- #include "PointObject.h"
- #endif
- #ifndef Range_h
- #include "Range.h"
- #endif
-
- class Rectangle: public Rect
- {
- public:
- Rectangle() {}
- Rectangle( const Rect& r ) : Rect( r ) {}
- Rectangle( int16 l, int16 t, int16 r, int16 b ) { left = l; top = t; right = r; bottom = b; }
- Rectangle( Point p1, Point p2 );
-
- static const Rectangle big;
- static const Rectangle zero;
-
- PointObject TopLeft() const { return PointObject( left, top ); }
- PointObject TopRight() const { return PointObject( right, top ); }
- PointObject BottomLeft() const { return PointObject( left, bottom ); }
- PointObject BottomRight() const { return PointObject( right, bottom ); }
-
- void SetTopLeft( Point p ) { left = p.h; top = p.v; }
- void SetTopRight( Point p ) { right = p.h; top = p.v; }
- void SetBottomLeft( Point p ) { left = p.h; bottom = p.v; }
- void SetBottomRight( Point p ) { right = p.h; bottom = p.v; }
-
- bool IsEmpty() const { return left >= right || top >= bottom; }
- bool IsNormal() const { return left <= right && top <= bottom; }
- bool Contains( Point p ) const;
- bool StrictlyContains( Point p ) const;
- bool WeaklyContains( Point p ) const;
-
- void operator=( Rect r ) { *(Rect *)this = r; }
-
- bool operator==( Rect r ) const;
- bool operator!=( Rect r ) const { return !(*this == r); }
- bool operator<=( Rect r ) const;
- bool operator>=( Rect r ) const;
- bool operator<( Rect r ) const { return *this <= r && *this != r; }
- bool operator>( Rect r ) const { return *this >= r && *this != r; }
-
- void operator&=( Rect r );
- void operator|=( Rect r );
- Rectangle operator&( Rect r ) const;
- Rectangle operator|( Rect r ) const;
-
- bool Intersects( Rect r ) const;
- bool Touches( Rect r ) const;
-
- uint32 SharedSides( Rect r ) const;
-
- void operator+=( Rect r );
- void operator-=( Rect r );
- Rectangle operator+( Rect r ) const;
- Rectangle operator-( Rect r ) const;
-
- void Inset( int16 amount );
- void Inset( Point amount );
- void Inset( Rect amount );
- void Outset( int16 amount );
- void Outset( Point amount );
- void Outset( Rect amount );
-
- void operator+=( Point vector );
- void operator-=( Point vector );
- Rectangle operator+( Point vector ) const;
- Rectangle operator-( Point vector ) const;
-
- uint32 Height() const { return uint32( bottom ) - uint32( top ); }
- uint32 Width() const { return uint32( right ) - uint32( left ); }
- PointObject Size() const;
- uint32 Bulk() const;
- uint32 Area() const;
- uint32 TaxicabDistanceTo( Point p ) const;
- uint32 TaxicabDistanceTo( Rect r ) const;
-
- Range<int16> Vertical() const { return Range<int16>( top, bottom ); }
- Range<int16> Horizontal() const { return Range<int16>( left, right ); }
-
- void GlobalToLocal();
- void LocalToGlobal();
- };
-
- #endif
-